const express = require('express');

const app = express();

// 实现功能
// 请求： http://127.0.0.1:8080/?page=frontend
app.get('/', (request, response)=>{
    // 根据 获取查询字符串参数page的值进行响应 request.query
    let page = request.query.page;
    // console.log(page,request.query);
    if(page === 'frontend'){
        response.send(`<h1>前端页面</h1>
        <a href="/?page=frontend">前端页面</a>
        <a href="/?page=backend">后端页面</a>
        <a href="/?page=vue">vue页面</a>`)
    }
    if(page === 'backend'){
        response.send(`<h1>后端页面</h1>
        <a href="/?page=frontend">前端页面</a>
        <a href="/?page=backend">后端页面</a>
        <a href="/?page=vue">vue页面</a>`)
    }
    if(page === 'vue'){
        response.send(`<h1>vue页面</h1>
        <a href="/?page=frontend">前端页面</a>
        <a href="/?page=backend">后端页面</a>
        <a href="/?page=vue">vue页面</a>`)
    }
    
})

app.listen(8080,()=>{console.log('server run at 8080')})